# -*- coding: utf-8 -*-
"""
    Created by huangyi at 2020/7/30.
    Description:
    Changelog: all notable changes to this file will be documented
"""
from ....expression.context import Context
from ....expression.exception.invalid_exception import InvalidException
from ....expression.nonterminal.func.func import Func


class Between(Func):

    def get_name(self) -> str:
        return "between"

    def calc(self, ctx: Context, *param):
        if len(param) != 3:
            raise InvalidException("参数必须有三个")
        data = param[0]
        begin = param[1]
        end = param[2]
        return begin <= data <= end
